/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ccedeno
 *  SELECT t FROM Trabajador t join t.usuario u  WHERE u.idUsuario = :codtra   ok  Join
 *     @NamedQuery(name = "MovExp.findIdExpedi", query = "SELECT e FROM Expediente e join e.ExpCod m  WHERE m.fkExp = :Exp"),
 */
@Entity
@Table(name = "mov_exp", catalog = "emilima_tradoc", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "MovExp.findAll", query = "SELECT m FROM MovExp m"),
    @NamedQuery(name = "MovExp.findByIdMovExp", query = "SELECT m FROM MovExp m WHERE m.idMovExp = :idMovExp"),
    @NamedQuery(name = "MovExp.findByNumdocEmitido", query = "SELECT m FROM MovExp m WHERE m.numdocEmitido = :numdocEmitido"),
    @NamedQuery(name = "MovExp.findByFolios", query = "SELECT m FROM MovExp m WHERE m.folios = :folios"),
    @NamedQuery(name = "MovExp.findByAsunto", query = "SELECT m FROM MovExp m WHERE m.asunto = :asunto"),
    @NamedQuery(name = "MovExp.findIdExpedi", query = "SELECT m FROM MovExp m WHERE m.expediente.codExp = :fkexp"),
                                                    // SELECT i FROM InteresArea i WHERE i.interesAreaPK.idInter = :idInter
    @NamedQuery(name = "MovExp.findByFecha", query = "SELECT m FROM MovExp m WHERE m.fecha = :fecha"),
    @NamedQuery(name = "MovExp.findByResMd5", query = "SELECT m FROM MovExp m WHERE m.resMd5 = :resMd5")})
public class MovExp implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_mov_exp", nullable = false)
    private Integer idMovExp;
        
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 8)
    @Column(name = "numdoc_emitido", nullable = false, length = 8)
    private String numdocEmitido;
    @Column(name = "folios")
    private Integer folios;
    @Lob
    @Size(max = 65535)
    @Column(name = "observacion", length = 65535)
    private String observacion;
    @Size(max = 255)
    @Column(name = "asunto", length = 255)
    private String asunto;
    @Column(name = "fecha")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecha;
    @Size(max = 32)
    @Column(name = "res_md5", length = 32)
    private String resMd5;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "movExp", fetch = FetchType.LAZY)
    private List<DetAccMov> detAccMovList;
    @JoinColumn(name = "fk_tipo_doc_interno", referencedColumnName = "id_tipo_doc_interno", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private TipoDocInterno tipoDocInterno;
    @JoinColumn(name = "fk_res_emisor", referencedColumnName = "id_responsable", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Trabajador trabajador;
    @JoinColumn(name = "fk_exp", referencedColumnName = "cod_exp", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Expediente expediente;
    @JoinColumn(name = "fk_estado", referencedColumnName = "id_estado", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Estado estado;
    @JoinColumn(name = "fk_area_recept", referencedColumnName = "idarea")
    @ManyToOne(fetch = FetchType.LAZY)
    private Area area;
    @JoinColumn(name = "fk_area", referencedColumnName = "idarea", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Area area1;

    public MovExp() {
    }

    public MovExp(Integer idMovExp) {
        this.idMovExp = idMovExp;
    }

    public MovExp(Integer idMovExp, String numdocEmitido) {
        this.idMovExp = idMovExp;
        this.numdocEmitido = numdocEmitido;
    }

    public MovExp(Integer idMovExp,String fecha, String numdocEmitido) {
        this.idMovExp = idMovExp;
        this.numdocEmitido = numdocEmitido;
    }

    
    public Integer getIdMovExp() {
        return idMovExp;
    }

    public void setIdMovExp(Integer idMovExp) {
        this.idMovExp = idMovExp;
    }

    public String getNumdocEmitido() {
        return numdocEmitido;
    }

    public void setNumdocEmitido(String numdocEmitido) {
        this.numdocEmitido = numdocEmitido;
    }

    public Integer getFolios() {
        return folios;
    }

    public void setFolios(Integer folios) {
        this.folios = folios;
    }

    public String getObservacion() {
        return observacion;
    }

    public void setObservacion(String observacion) {
        this.observacion = observacion;
    }

    public String getAsunto() {
        return asunto;
    }

    public void setAsunto(String asunto) {
        this.asunto = asunto;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public String getResMd5() {
        return resMd5;
    }

    public void setResMd5(String resMd5) {
        this.resMd5 = resMd5;
    }

    @XmlTransient
    public List<DetAccMov> getDetAccMovList() {
        return detAccMovList;
    }

    public void setDetAccMovList(List<DetAccMov> detAccMovList) {
        this.detAccMovList = detAccMovList;
    }

    public TipoDocInterno getTipoDocInterno() {
        return tipoDocInterno;
    }

    public void setTipoDocInterno(TipoDocInterno tipoDocInterno) {
        this.tipoDocInterno = tipoDocInterno;
    }

    public Trabajador getTrabajador() {
        return trabajador;
    }

    public void setTrabajador(Trabajador trabajador) {
        this.trabajador = trabajador;
    }

    public Expediente getExpediente() {
        return expediente;
    }

    public void setExpediente(Expediente expediente) {
        this.expediente = expediente;
    }

    public Estado getEstado() {
        return estado;
    }

    public void setEstado(Estado estado) {
        this.estado = estado;
    }

    public Area getArea() {
        return area;
    }

    public void setArea(Area area) {
        this.area = area;
    }

    public Area getArea1() {
        return area1;
    }

    public void setArea1(Area area1) {
        this.area1 = area1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idMovExp != null ? idMovExp.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MovExp)) {
            return false;
        }
        MovExp other = (MovExp) object;
        if ((this.idMovExp == null && other.idMovExp != null) || (this.idMovExp != null && !this.idMovExp.equals(other.idMovExp))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entidades.MovExp[ idMovExp=" + idMovExp + " ]";
      //   return idMovExp;
    }
}
